#pragma once

#include "ArmyEntity.h"
#include "RunningSoldierEntity.h"

#include "GunState.h"
#include "GunPhysics.h"

#include "RedGunState.h"
#include "RedGunPhysics.h"

#include "RedSoldierState.h"
#include "RedSoldierPhysics.h"

#include "RunningSoldierPhysics.h"
#include "RunningSoldierState.h"

#include "HiddenSoldierState.h"
#include "HiddenSoldierPhysics.h"

class ArmyEnttiyFactory {
public:
	static ArmyEntity* getArmyEntity(int id, int type, double x, double y,Rect* targetRect, Rect* rangeOfEffect) {
		ArmyEntity* armyEntity = new ArmyEntity(id, type, x, y, rangeOfEffect);
		IArmyState* armyState = NULL;
		IArmyPhysics* armyPhysics = NULL;

		armyEntity->setTargetRect(targetRect);

		switch (type) {
		case _ID_ARMY_GUN_1:
			armyState = new GunState(armyEntity->getArmyData());
			armyPhysics = new GunPhysics(armyEntity->getArmyData());
			break;
		case _ID_ARMY_RED_SOLDIER:	
			armyState = new RedSoldierState(armyEntity->getArmyData());
			armyPhysics = new RedSoldierPhysics(armyEntity->getArmyData());
			break;
		case _ID_ARMY_RUNNING_SOLDIER:
			delete armyEntity;
			armyEntity = new RunningSoldierEntity(id, type, x, y, rangeOfEffect);
			armyEntity->setTargetRect(targetRect);
			armyState = new RunningSoldierState(armyEntity->getArmyData());
			armyPhysics = new RunningSoldierPhysics(armyEntity->getArmyData());
			break;
		case _ID_ARMY_GUN_2:
			armyState = new RedGunState(armyEntity->getArmyData());
			armyPhysics = new RedGunPhysics(armyEntity->getArmyData());
			break;
		case _ID_ARMY_RED_HIDDEN:
			armyState = new HiddenSoldierState(armyEntity->getArmyData());
			armyPhysics = new HiddenSoldierPhysics(armyEntity->getArmyData());
			break;
		}

		armyState->initSprites();
		armyEntity->setRefPattern(armyState, armyPhysics);

		return armyEntity;
	}
};